package com.gitee.maskit.nop.autoconfigure;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class NopInvocationHandler implements InvocationHandler {
    private final NopProvider provider;

    public NopInvocationHandler(NopProvider provider) {
        this.provider = provider;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        final Class returnType = method.getReturnType();
        if (void.class.equals(returnType)) {
            provider.apply(method, args);
            return null;
        }
        return provider.apply(method, args);
    }
}
